package com.ruoyi.eam.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.eam.doman.EamReturnD;
import com.ruoyi.eam.service.IEamReturnDService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 资产退还从Controller
 * 
 * @author ruoyi
 * @date 2024-07-09
 */
@RestController
@RequestMapping("/returnD")
public class EamReturnDController extends BaseController
{
    @Autowired
    private IEamReturnDService eamReturnDService;

    /**
     * 查询资产退还从列表
     */
    //@RequiresPermissions("return:d:list")
    @GetMapping("/list")
    public TableDataInfo list(EamReturnD eamReturnD)
    {
        startPage();
        List<EamReturnD> list = eamReturnDService.selectEamReturnDList(eamReturnD);
        return getDataTable(list);
    }

    /**
     * 导出资产退还从列表
     */
    //@RequiresPermissions("return:d:export")
    @Log(title = "资产退还从", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EamReturnD eamReturnD)
    {
        List<EamReturnD> list = eamReturnDService.selectEamReturnDList(eamReturnD);
        ExcelUtil<EamReturnD> util = new ExcelUtil<EamReturnD>(EamReturnD.class);
        util.exportExcel(response, list, "资产退还从数据");
    }

    /**
     * 获取资产退还从详细信息
     */
//    @RequiresPermissions("return:d:query")
    @GetMapping(value = "/{assetId}")
    public AjaxResult getInfo(@PathVariable("assetId") String manageId)
    {
        return success(eamReturnDService.selectEamReturnDByAssetId(manageId));
    }

    /**
     * 新增资产退还从
     */
    //@RequiresPermissions("return:d:add")
    @Log(title = "资产退还从", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EamReturnD eamReturnD)
    {
        return toAjax(eamReturnDService.insertEamReturnD(eamReturnD));
    }

    /**
     * 修改资产退还从
     */
    //@RequiresPermissions("return:d:edit")
    @Log(title = "资产退还从", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EamReturnD eamReturnD)
    {
        return toAjax(eamReturnDService.updateEamReturnD(eamReturnD));
    }

    /**
     * 删除资产退还从
     */
    //@RequiresPermissions("return:d:remove")
    @Log(title = "资产退还从", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assetIds}")
    public AjaxResult remove(@PathVariable String[] manageId)
    {
        return toAjax(eamReturnDService.deleteEamReturnDByAssetIds(manageId));
    }
}
